package com.jinsi.controller.yrf;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinsi.constant.YrfConstant;
import com.jinsi.pojo.SyMicrocircleList;
import com.jinsi.service.yrf.MicrocircleListService;
import com.jinsi.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: 86185
 * @description: 微圈管理
 * @date 2022/9/10
 */
@RestController
@RequestMapping("/microcycleManagement")
public class MicrocircleListController {

    @Autowired
    private MicrocircleListService microcircleListService;

    /**
     * 获取微圈所有数据(模糊查询)
     */

    @RequestMapping("/getAll")
    public R getAll(Integer page, Integer limit,String sorw,SyMicrocircleList syMicrocircleList){
        System.out.println(syMicrocircleList);
        PageHelper.startPage(page,limit);
        List<SyMicrocircleList> all = microcircleListService.getAll(syMicrocircleList,sorw);
        PageInfo<SyMicrocircleList> pageInfo = new PageInfo<>(all);

        return R.custom(YrfConstant.LAYUI_CODE,
                YrfConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());

    }

    /**
     * 获取个人微圈所有数据(模糊查询)
     * @param syMicrocircleList 模糊查
     * @param userId 根据userId查询
     */

    @RequestMapping("/getAll2")
    public R getAll2(Integer page, Integer limit, Integer userId,SyMicrocircleList syMicrocircleList){
        System.out.println(syMicrocircleList);
        PageHelper.startPage(page,limit);
        List<SyMicrocircleList> all = microcircleListService.getAll2(syMicrocircleList,userId);
        PageInfo<SyMicrocircleList> pageInfo = new PageInfo<>(all);

        return R.custom(YrfConstant.LAYUI_CODE,
                YrfConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());

    }

    /**
     * 修改状态
     * @param id 根据id
     * @param reviewStatus 修改状态
     */
    @RequestMapping("/upReviewStatus")
    public R upReviewStatus(int id,int reviewStatus){
        microcircleListService.upReviewStatus(id,reviewStatus);
        return R.ok("成功");

    }
}
